package cn.iocoder.yudao.module.movie.serive.movieInfCache;

import cn.iocoder.yudao.module.movie.api.domain.CityDO;
import cn.iocoder.yudao.module.movie.api.domain.MovieCinemasDO;
import cn.iocoder.yudao.module.movie.api.params.MovieCinemaParamDO;
import cn.iocoder.yudao.module.movie.factory.MovieInfFactory;
import cn.iocoder.yudao.module.movie.api.domain.MovieListDO;
import cn.iocoder.yudao.module.movie.enums.MovieInfEnum;
import cn.iocoder.yudao.module.movie.serive.movieInf.MovieInfService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>  </p>
 */
@Service
@Slf4j
public class MovieInfCacheRedisServiceImpl implements MovieInfCacheService{

    /**
     * 获取热映电影
     *
     * @param cityId 城市id
     * @return 热映电影
     */
    @Override
    @Cacheable(cacheNames = "movie:hot-list", key = "#cityId",
            unless = "#result == null")
    public MovieListDO getHotList(String cityId) {
        MovieInfService movieInfService = MovieInfFactory.getMovieInfService(MovieInfEnum.YOU_PIAO_PIAO);
        return movieInfService.getMovies(cityId);
    }

    /**
     * 获取即将上映电影
     *
     * @param cityId 城市id
     * @return 即将上映电影
     */
    @Override
    @Cacheable(cacheNames = "movie:coming-list", key = "#cityId",
            unless = "#result == null")
    public MovieListDO getComingList(String cityId) {
        MovieInfService movieInfService = MovieInfFactory.getMovieInfService(MovieInfEnum.YOU_PIAO_PIAO);
        return movieInfService.getComingMovies(cityId);
    }

    /**
     * 获取城市列表
     *
     * @return 城市列表
     */
    @Override
    @Cacheable(cacheNames = "movie:city-list",
            unless = "#result == null")
    public List<CityDO> getCityList() {
        MovieInfService movieInfService = MovieInfFactory.getMovieInfService(MovieInfEnum.YOU_PIAO_PIAO);
        return movieInfService.getCityList();
    }

    /**
     * 获取电影的影院信息
     *
     * @param paramDO 影院参数
     * @return 影院信息
     */
    @Override
    public MovieCinemasDO getMovieCinemas(MovieCinemaParamDO paramDO) {
        MovieInfService movieInfService = MovieInfFactory.getMovieInfService(MovieInfEnum.YOU_PIAO_PIAO);
        return movieInfService.getMovieCinemas(paramDO);
    }
}
